package com.nidu.demo.mail;

import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.mail.api.SysMailLogService;
import com.nidu.demo.mail.dto.*;
import com.nidu.demo.mail.executor.command.*;
import com.nidu.demo.mail.executor.query.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 邮件日志服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysMailLogServiceImpl implements SysMailLogService {

    private final MailLogSingleQryExe singleQryExe;
    private final MailLogPageQryExe pageQryExe;
    private final MailLogDeleteCmdExe deleteCmdExe;
    private final MailSendCmdExe mailSendCmdExe;

    @Override
    public Response sendMail(Long userId, Integer userType, MailSendCmd cmd) {
        return mailSendCmdExe.execute(userId, userType, cmd);
    }

    @Override
    public Response resendMail(Long id) {
        return mailSendCmdExe.execute(id);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<MailLogCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public PageResponse<MailLogCO> page(MailLogPageQry qry) {
        return pageQryExe.execute(qry);
    }

}
